
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>服务与依赖注入 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../comAndtem/" />
    
    
    <link rel="prev" href="component.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Angular-cli/">
            
                <a href="../Angular-cli/">
            
                    
                    Angular-cli
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../Angular-cli/Angular-cli.html">
            
                <a href="../Angular-cli/Angular-cli.html">
            
                    
                    安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../Angular-cli/restMenu.html">
            
                <a href="../Angular-cli/restMenu.html">
            
                    
                    初始结构
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="./">
            
                <a href="./">
            
                    
                    架构
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="mo-kuai.html">
            
                <a href="mo-kuai.html">
            
                    
                    模块简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="component.html">
            
                <a href="component.html">
            
                    
                    组件简介
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.3" data-path="Service.html">
            
                <a href="Service.html">
            
                    
                    服务与依赖注入
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../comAndtem/">
            
                <a href="../comAndtem/">
            
                    
                    组件与模板
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../comAndtem/zu-jian-yu-mo-ban.html">
            
                <a href="../comAndtem/zu-jian-yu-mo-ban.html">
            
                    
                    数据显示与模板语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../comAndtem/cycle.html">
            
                <a href="../comAndtem/cycle.html">
            
                    
                    生命周期钩子
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../comAndtem/component.html">
            
                <a href="../comAndtem/component.html">
            
                    
                    组件交互
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../comAndtem/style.html">
            
                <a href="../comAndtem/style.html">
            
                    
                    组件样式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../comAndtem/dynamic.html">
            
                <a href="../comAndtem/dynamic.html">
            
                    
                    动态组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../comAndtem/directive.html">
            
                <a href="../comAndtem/directive.html">
            
                    
                    属性指令与结构指令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../comAndtem/pipeAndAnimit.html">
            
                <a href="../comAndtem/pipeAndAnimit.html">
            
                    
                    管道与动画
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../router/">
            
                <a href="../router/">
            
                    
                    路由与导航
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../form/">
            
                <a href="../form/">
            
                    
                    表单
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../http/">
            
                <a href="../http/">
            
                    
                    请求http
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../project/">
            
                <a href="../project/">
            
                    
                    项目解析:结构目录
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >服务与依赖注入</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <p>&#x670D;&#x52A1;&#x662F;&#x4E00;&#x4E2A;&#x5E7F;&#x4E49;&#x7684;&#x6982;&#x5FF5;&#xFF0C;&#x5B83;&#x5305;&#x62EC;&#x5E94;&#x7528;&#x6240;&#x9700;&#x7684;&#x4EFB;&#x4F55;&#x503C;&#x3001;&#x51FD;&#x6570;&#x6216;&#x7279;&#x6027;&#x3002;&#x72ED;&#x4E49;&#x7684;&#x670D;&#x52A1;&#x662F;&#x4E00;&#x4E2A;&#x660E;&#x786E;&#x5B9A;&#x4E49;&#x4E86;&#x7528;&#x9014;&#x7684;&#x7C7B;&#x3002;&#x5B83;&#x5E94;&#x8BE5;&#x505A;&#x4E00;&#x4E9B;&#x5177;&#x4F53;&#x7684;&#x4E8B;&#xFF0C;&#x5E76;&#x505A;&#x597D;&#x3002;</p>
<p>Angular &#x628A;&#x7EC4;&#x4EF6;&#x548C;&#x670D;&#x52A1;&#x533A;&#x5206;&#x5F00;&#xFF0C;&#x4EE5;&#x63D0;&#x9AD8;&#x6A21;&#x5757;&#x6027;&#x548C;&#x590D;&#x7528;&#x6027;</p>
<ul>
<li><p>&#x901A;&#x8FC7;&#x628A;&#x7EC4;&#x4EF6;&#x4E2D;&#x548C;&#x89C6;&#x56FE;&#x6709;&#x5173;&#x7684;&#x529F;&#x80FD;&#x4E0E;&#x5176;&#x4ED6;&#x7C7B;&#x578B;&#x7684;&#x5904;&#x7406;&#x5206;&#x79BB;&#x5F00;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x8BA9;&#x7EC4;&#x4EF6;&#x7C7B;&#x66F4;&#x52A0;&#x7CBE;&#x7B80;&#x3001;&#x9AD8;&#x6548;&#x3002; &#x7406;&#x60F3;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x7EC4;&#x4EF6;&#x7684;&#x5DE5;&#x4F5C;&#x53EA;&#x7BA1;&#x7528;&#x6237;&#x4F53;&#x9A8C;&#xFF0C;&#x800C;&#x4E0D;&#x7528;&#x987E;&#x53CA;&#x5176;&#x5B83;&#x3002; &#x5B83;&#x5E94;&#x8BE5;&#x63D0;&#x4F9B;&#x7528;&#x4E8E;&#x6570;&#x636E;&#x7ED1;&#x5B9A;&#x7684;&#x5C5E;&#x6027;&#x548C;&#x65B9;&#x6CD5;&#xFF0C;&#x4EE5;&#x4FBF;&#x4F5C;&#x4E3A;&#x89C6;&#x56FE;&#xFF08;&#x7531;&#x6A21;&#x677F;&#x6E32;&#x67D3;&#xFF09;&#x548C;&#x5E94;&#x7528;&#x903B;&#x8F91;&#xFF08;&#x901A;&#x5E38;&#x5305;&#x542B;&#x4E00;&#x4E9B;&#x6A21;&#x578B;&#x7684;&#x6982;&#x5FF5;&#xFF09;&#x7684;&#x4E2D;&#x4ECB;&#x8005;&#x3002;</p>
</li>
<li><p>&#x7EC4;&#x4EF6;&#x4E0D;&#x5E94;&#x8BE5;&#x5B9A;&#x4E49;&#x4EFB;&#x4F55;&#x8BF8;&#x5982;&#x4ECE;&#x670D;&#x52A1;&#x5668;&#x83B7;&#x53D6;&#x6570;&#x636E;&#x3001;&#x9A8C;&#x8BC1;&#x7528;&#x6237;&#x8F93;&#x5165;&#x6216;&#x76F4;&#x63A5;&#x5F80;&#x63A7;&#x5236;&#x53F0;&#x4E2D;&#x5199;&#x65E5;&#x5FD7;&#x7B49;&#x5DE5;&#x4F5C;&#x3002; &#x800C;&#x8981;&#x628A;&#x8FD9;&#x4E9B;&#x4EFB;&#x52A1;&#x59D4;&#x6258;&#x7ED9;&#x5404;&#x79CD;&#x670D;&#x52A1;&#x3002;&#x901A;&#x8FC7;&#x628A;&#x5404;&#x79CD;&#x5904;&#x7406;&#x4EFB;&#x52A1;&#x5B9A;&#x4E49;&#x5230;&#x53EF;&#x6CE8;&#x5165;&#x7684;&#x670D;&#x52A1;&#x7C7B;&#x4E2D;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x8BA9;&#x5B83;&#x53EF;&#x4EE5;&#x88AB;&#x4EFB;&#x4F55;&#x7EC4;&#x4EF6;&#x4F7F;&#x7528;&#x3002; &#x901A;&#x8FC7;&#x5728;&#x4E0D;&#x540C;&#x7684;&#x73AF;&#x5883;&#x4E2D;&#x6CE8;&#x5165;&#x540C;&#x4E00;&#x79CD;&#x670D;&#x52A1;&#x7684;&#x4E0D;&#x540C;&#x63D0;&#x4F9B;&#x5546;&#xFF0C;&#x4F60;&#x8FD8;&#x53EF;&#x4EE5;&#x8BA9;&#x4F60;&#x7684;&#x5E94;&#x7528;&#x66F4;&#x5177;&#x9002;&#x5E94;&#x6027;&#x3002;</p>
</li>
</ul>
<p>Angular &#x4E0D;&#x4F1A;&#x5F3A;&#x5236;&#x9075;&#x5FAA;&#x8FD9;&#x4E9B;&#x539F;&#x5219;&#x3002;&#x5B83;&#x53EA;&#x4F1A;&#x901A;&#x8FC7;<strong>&#x4F9D;&#x8D56;&#x6CE8;&#x5165;</strong>&#x8BA9;&#x4F60;&#x80FD;&#x66F4;&#x5BB9;&#x6613;&#x5730;&#x5C06;&#x5E94;&#x7528;&#x903B;&#x8F91;&#x5206;&#x89E3;&#x4E3A;&#x670D;&#x52A1;&#xFF0C;&#x5E76;&#x8BA9;&#x8FD9;&#x4E9B;&#x670D;&#x52A1;&#x53EF;&#x7528;&#x4E8E;&#x5404;&#x4E2A;&#x7EC4;&#x4EF6;&#x4E2D;&#x3002;</p>
<h4 id="&#x670D;&#x52A1;&#x8303;&#x4F8B;">&#x670D;&#x52A1;&#x8303;&#x4F8B;</h4>
<pre><code>export class Logger {
  log(msg: any)   { console.log(msg); }
  error(msg: any) { console.error(msg); }
  warn(msg: any)  { console.warn(msg); }
}
</code></pre><p>&#x670D;&#x52A1;&#x4E5F;&#x53EF;&#x4EE5;&#x4F9D;&#x8D56;&#x5176;&#x5B83;&#x670D;&#x52A1;&#x3002;</p>
<pre><code>constructor(
    private backend: BackendService,
    private logger: Logger) { }
</code></pre><h3 id="&#x4F9D;&#x8D56;&#x6CE8;&#x5165;">&#x4F9D;&#x8D56;&#x6CE8;&#x5165;</h3>
<p>&#x7EC4;&#x4EF6;&#x662F;&#x670D;&#x52A1;&#x7684;&#x6D88;&#x8D39;&#x8005;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x628A;&#x4E00;&#x4E2A;&#x670D;&#x52A1;&#x6CE8;&#x5165;&#x5230;&#x7EC4;&#x4EF6;&#x4E2D;&#xFF0C;&#x8BA9;&#x7EC4;&#x4EF6;&#x7C7B;&#x5F97;&#x4EE5;&#x8BBF;&#x95EE;&#x8BE5;&#x670D;&#x52A1;&#x7C7B;&#x3002;</p>
<p>&#x5728; Angular &#x4E2D;&#xFF0C;&#x8981;&#x628A;&#x4E00;&#x4E2A;&#x7C7B;&#x5B9A;&#x4E49;&#x4E3A;&#x670D;&#x52A1;&#xFF0C;&#x5C31;&#x8981;&#x7528; <code>@Injectable</code> &#x88C5;&#x9970;&#x5668;&#x6765;&#x63D0;&#x4F9B;&#x5143;&#x6570;&#x636E;&#xFF0C;&#x4EE5;&#x4FBF;&#x8BA9; Angular &#x53EF;&#x4EE5;&#x628A;&#x5B83;&#x4F5C;&#x4E3A;&#x4F9D;&#x8D56;&#x6CE8;&#x5165;&#x5230;&#x7EC4;&#x4EF6;&#x4E2D;&#x3002;</p>
<p>&#x4F9D;&#x8D56;&#x6CE8;&#x5165;&#xFF08;&#x901A;&#x5E38;&#x7B80;&#x79F0; DI&#xFF09;&#x88AB;&#x5F15;&#x5165;&#x5230; Angular &#x6846;&#x67B6;&#x4E2D;&#xFF0C;&#x5E76;&#x4E14;&#x5230;&#x5904;&#x4F7F;&#x7528;&#x5B83;&#xFF0C;&#x6765;&#x4E3A;&#x65B0;&#x5EFA;&#x7684;&#x7EC4;&#x4EF6;&#x63D0;&#x4F9B;&#x6240;&#x9700;&#x7684;&#x670D;&#x52A1;&#x6216;&#x5176;&#x5B83;&#x4E1C;&#x897F;&#x3002;</p>
<ul>
<li><p>&#x6CE8;&#x5165;&#x5668;&#x662F;&#x4E3B;&#x8981;&#x7684;&#x673A;&#x5236;&#x3002;&#x4F60;&#x4E0D;&#x7528;&#x81EA;&#x5DF1;&#x521B;&#x5EFA; Angular &#x6CE8;&#x5165;&#x5668;&#x3002;Angular &#x4F1A;&#x5728;&#x542F;&#x52A8;&#x8FC7;&#x7A0B;&#x4E2D;&#x4E3A;&#x4F60;&#x521B;&#x5EFA;&#x5168;&#x5E94;&#x7528;&#x7EA7;&#x6CE8;&#x5165;&#x5668;&#x3002;</p>
</li>
<li><p>&#x8BE5;&#x6CE8;&#x5165;&#x5668;&#x7EF4;&#x62A4;&#x4E00;&#x4E2A;&#x5305;&#x542B;&#x5B83;&#x5DF2;&#x521B;&#x5EFA;&#x7684;&#x4F9D;&#x8D56;&#x5B9E;&#x4F8B;&#x7684;&#x5BB9;&#x5668;&#xFF0C;&#x5E76;&#x5C3D;&#x53EF;&#x80FD;&#x590D;&#x7528;&#x5B83;&#x4EEC;&#x3002;</p>
</li>
<li><p>&#x63D0;&#x4F9B;&#x5546;&#x662F;&#x4E00;&#x4E2A;&#x521B;&#x5EFA;&#x4F9D;&#x8D56;&#x7684;&#x83DC;&#x8C31;&#x3002;&#x5BF9;&#x4E8E;&#x670D;&#x52A1;&#x6765;&#x8BF4;&#xFF0C;&#x5B83;&#x901A;&#x5E38;&#x5C31;&#x662F;&#x8FD9;&#x4E2A;&#x670D;&#x52A1;&#x7C7B;&#x672C;&#x8EAB;&#x3002;&#x4F60;&#x5728;&#x5E94;&#x7528;&#x4E2D;&#x8981;&#x7528;&#x5230;&#x7684;&#x4EFB;&#x4F55;&#x7C7B;&#x90FD;&#x5FC5;&#x987B;&#x4F7F;&#x7528;&#x8BE5;&#x5E94;&#x7528;&#x7684;&#x6CE8;&#x5165;&#x5668;&#x6CE8;&#x518C;&#x4E00;&#x4E2A;&#x63D0;&#x4F9B;&#x5546;&#xFF0C;&#x4EE5;&#x4FBF;&#x6CE8;&#x5165;&#x5668;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5B83;&#x6765;&#x521B;&#x5EFA;&#x65B0;&#x5B9E;&#x4F8B;&#x3002;</p>
</li>
<li><p>&#x5F53; Angular &#x521B;&#x5EFA;&#x7EC4;&#x4EF6;&#x7C7B;&#x7684;&#x65B0;&#x5B9E;&#x4F8B;&#x65F6;&#xFF0C;&#x5B83;&#x4F1A;&#x901A;&#x8FC7;&#x67E5;&#x770B;&#x8BE5;&#x7EC4;&#x4EF6;&#x7C7B;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#xFF0C;&#x6765;&#x51B3;&#x5B9A;&#x8BE5;&#x7EC4;&#x4EF6;&#x4F9D;&#x8D56;&#x54EA;&#x4E9B;&#x670D;&#x52A1;&#x6216;&#x5176;&#x5B83;&#x4F9D;&#x8D56;&#x9879;&#x3002;</p>
</li>
</ul>
<p>&#x5F53; Angular &#x53D1;&#x73B0;&#x67D0;&#x4E2A;&#x7EC4;&#x4EF6;&#x4F9D;&#x8D56;&#x67D0;&#x4E2A;&#x670D;&#x52A1;&#x65F6;&#xFF0C;&#x5B83;&#x4F1A;&#x9996;&#x5148;&#x68C0;&#x67E5;&#x662F;&#x5426;&#x8BE5;&#x6CE8;&#x5165;&#x5668;&#x4E2D;&#x5DF2;&#x7ECF;&#x6709;&#x4E86;&#x90A3;&#x4E2A;&#x670D;&#x52A1;&#x7684;&#x4EFB;&#x4F55;&#x73B0;&#x6709;&#x5B9E;&#x4F8B;&#x3002;&#x5982;&#x679C;&#x6240;&#x8BF7;&#x6C42;&#x7684;&#x670D;&#x52A1;&#x5C1A;&#x4E0D;&#x5B58;&#x5728;&#xFF0C;&#x6CE8;&#x5165;&#x5668;&#x5C31;&#x4F1A;&#x4F7F;&#x7528;&#x4EE5;&#x524D;&#x6CE8;&#x518C;&#x7684;&#x670D;&#x52A1;&#x63D0;&#x4F9B;&#x5546;&#x6765;&#x5236;&#x4F5C;&#x4E00;&#x4E2A;&#xFF0C;&#x5E76;&#x628A;&#x5B83;&#x52A0;&#x5165;&#x6CE8;&#x5165;&#x5668;&#x4E2D;&#xFF0C;&#x7136;&#x540E;&#x628A;&#x8BE5;&#x670D;&#x52A1;&#x8FD4;&#x56DE;&#x7ED9; Angular&#x3002;</p>
<p>&#x5F53;&#x6240;&#x6709;&#x8BF7;&#x6C42;&#x7684;&#x670D;&#x52A1;&#x5DF2;&#x89E3;&#x6790;&#x5E76;&#x8FD4;&#x56DE;&#x65F6;&#xFF0C;Angular &#x53EF;&#x4EE5;&#x7528;&#x8FD9;&#x4E9B;&#x670D;&#x52A1;&#x5B9E;&#x4F8B;&#x4E3A;&#x53C2;&#x6570;&#xFF0C;&#x8C03;&#x7528;&#x8BE5;&#x7EC4;&#x4EF6;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#x3002;</p>
<h3 id="&#x63D0;&#x4F9B;&#x670D;&#x52A1;">&#x63D0;&#x4F9B;&#x670D;&#x52A1;</h3>
<p>&#x5BF9;&#x4E8E;&#x8981;&#x7528;&#x5230;&#x7684;&#x4EFB;&#x4F55;&#x670D;&#x52A1;&#xFF0C;&#x4F60;&#x5FC5;&#x987B;&#x81F3;&#x5C11;&#x6CE8;&#x518C;&#x4E00;&#x4E2A;&#x63D0;&#x4F9B;&#x5546;&#x3002;&#x4F60;&#x53EF;&#x4EE5;&#x5728;&#x6A21;&#x5757;&#x4E2D;&#x6216;&#x8005;&#x7EC4;&#x4EF6;&#x4E2D;&#x6CE8;&#x518C;&#x8FD9;&#x4E9B;&#x63D0;&#x4F9B;&#x5546;&#x3002;</p>
<ul>
<li>&#x5F53;&#x4F60;&#x5F80;&#x6839;&#x6A21;&#x5757;&#x4E2D;&#x6DFB;&#x52A0;&#x670D;&#x52A1;&#x63D0;&#x4F9B;&#x5546;&#x65F6;&#xFF0C;&#x670D;&#x52A1;&#x7684;&#x540C;&#x4E00;&#x4E2A;&#x5B9E;&#x4F8B;&#x4F1A;&#x670D;&#x52A1;&#x4E8E;&#x4F60;&#x5E94;&#x7528;&#x4E2D;&#x7684;&#x6240;&#x6709;&#x7EC4;&#x4EF6;&#x3002;</li>
</ul>
<pre><code>providers: [
  BackendService,
  HeroService,
  Logger
],
</code></pre><ul>
<li>&#x5F53;&#x4F60;&#x5728;&#x7EC4;&#x4EF6;&#x7EA7;&#x6CE8;&#x518C;&#x63D0;&#x4F9B;&#x5546;&#x65F6;&#xFF0C;&#x4F60;&#x4F1A;&#x4E3A;&#x8BE5;&#x7EC4;&#x4EF6;&#x7684;&#x6BCF;&#x4E00;&#x4E2A;&#x65B0;&#x5B9E;&#x4F8B;&#x63D0;&#x4F9B;&#x8BE5;&#x670D;&#x52A1;&#x7684;&#x4E00;&#x4E2A;&#x65B0;&#x5B9E;&#x4F8B;&#x3002; &#x8981;&#x5728;&#x7EC4;&#x4EF6;&#x7EA7;&#x6CE8;&#x518C;&#xFF0C;&#x5C31;&#x8981;&#x5728; @Component &#x5143;&#x6570;&#x636E;&#x7684; <code>providers</code> &#x5C5E;&#x6027;&#x4E2D;&#x6CE8;&#x518C;&#x670D;&#x52A1;&#x63D0;&#x4F9B;&#x5546;&#x3002;</li>
</ul>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="component.html" class="navigation navigation-prev " aria-label="Previous page: 组件简介">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../comAndtem/" class="navigation navigation-next " aria-label="Next page: 组件与模板">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"服务与依赖注入","level":"1.3.3","depth":2,"next":{"title":"组件与模板","level":"1.4","depth":1,"path":"comAndtem/README.md","ref":"comAndtem/README.md","articles":[{"title":"数据显示与模板语法","level":"1.4.1","depth":2,"path":"comAndtem/zu-jian-yu-mo-ban.md","ref":"comAndtem/zu-jian-yu-mo-ban.md","articles":[]},{"title":"生命周期钩子","level":"1.4.2","depth":2,"path":"comAndtem/cycle.md","ref":"comAndtem/cycle.md","articles":[]},{"title":"组件交互","level":"1.4.3","depth":2,"path":"comAndtem/component.md","ref":"comAndtem/component.md","articles":[]},{"title":"组件样式","level":"1.4.4","depth":2,"path":"comAndtem/style.md","ref":"comAndtem/style.md","articles":[]},{"title":"动态组件","level":"1.4.5","depth":2,"path":"comAndtem/dynamic.md","ref":"comAndtem/dynamic.md","articles":[]},{"title":"属性指令与结构指令","level":"1.4.6","depth":2,"path":"comAndtem/directive.md","ref":"comAndtem/directive.md","articles":[]},{"title":"管道与动画","level":"1.4.7","depth":2,"path":"comAndtem/pipeAndAnimit.md","ref":"comAndtem/pipeAndAnimit.md","articles":[]}]},"previous":{"title":"组件简介","level":"1.3.2","depth":2,"path":"architecture/component.md","ref":"architecture/component.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["fontsettings","sharing","lunr","search","highlight","livereload"],"pluginsConfig":{"fontsettings":{"family":"sans","size":2,"theme":"white"},"sharing":{"all":["facebook","google","twitter","weibo","instapaper"],"facebook":true,"google":false,"instapaper":false,"twitter":true,"vk":false,"weibo":false},"lunr":{"ignoreSpecialCharacters":false,"maxIndexSize":1000000},"search":{},"highlight":{},"livereload":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"architecture/Service.md","mtime":"2018-06-12T06:57:18.748Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-06-29T06:02:19.129Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    

    </body>
</html>

